<?php

/**
 * MVM_MALL 网上商店系统  前台邮件发送
 * ============================================================================
 * 版权所有 (C) 2007-2010 www.mvmmall.com，并保留所有权利。
 * 网站地址: http://www.mvmmall.com
 * ----------------------------------------------------------------------------
 * 这是一个免费开源的软件；这意味着您可以在不用于商业目的的前提下对程序代码
 * 进行修改、使用和再发布。
 * ============================================================================
 * $Author:  www.mvmmall.com  $
 * $Date: 2008-06-12 $
 * $Id: mailer.php  www.mvmmall.com$
 * ---------------------------------------------
*/

require_once 'include/common.inc.php';

/**发送邮件**/
if ($action=='sendemail') {
	if($setp==1){
		$mailer_html!= '1' && $mailer_body = dhtmlchars($mailer_body);
		$mailer_html==1?$mailer_type='html':$mailer_type='';
		include_once template('email_send');
		$mail_content = str_replace(array('<!--<!---->','<!---->','<!--fck-->',"\r",substr(MVMMALL_ROOT,0,-1)),'',ob_get_contents());
		ob_end_clean();
		smtp_mail($mailer_receive_email,$mail_subject,$mail_content,$mailer_type);
		unset($mail_content);
		show_msg('mall_send_mailer','./');
	}else {
		require_once MVMMALL_ROOT . 'header.php';
		$navigation = make_navigation($lang['email_submit'],"mailer.php?action=$action&ps_rmail=$ps_rmail&ps_rname=$ps_rname");//导航
		$ps_rmail = mango_decode($ps_rmail);
		require_once template('sendemail');
		footer();
	}
}

/**推荐商品**/
elseif ($action=='recommend' && is_numeric($uid)){
    $m_all_slink_dir = $mm_mall_url.'/'.$mm_mall_install_dir;
    $product = $db->get_one("SELECT goods_name,goods_market_price,goods_sale_price,uid,goods_file1,goods_code,goods_brand,goods_kg FROM `{$tablepre}goods_table` WHERE uid = '$uid'");
    $product['title']              = $product['goods_name'];
    $product['photo']              = $product['goods_file1'];
    $product['goods_market_price'] = currency($product['goods_market_price']);
    $product['goods_sale_price']   = currency($product['goods_sale_price']);
    $product['url']                = MVMMALL_DIR."/product.php?action=$product[uid]";
    $mm_brand                      = $cache->get_cache('brand');//品牌
    $product['goods_brand']        = $mm_brand[$product['goods_brand']];
    if($setp==1 && $_POST){
        /**发送邮件*/
        $mail_subject = $mailer_send_name.$lang['welcome']."!";
        include_once template('email_recommend');
        $mail_content = str_replace(array('<!--<!---->','<!---->','<!--fck-->',"\r",substr(MVMMALL_ROOT,0,-1)),'',ob_get_contents());
        ob_end_clean();
        smtp_mail($mailer_receive_email,$mail_subject,$mail_content,html);
        unset($mail_content);
        /**end**/
        show_msg('mall_send_mailer','./');
    }else {
        require_once MVMMALL_ROOT . 'header.php';
        $navigation = make_navigation($lang['email_goods'],"mailer.php?action=$action&uid=$uid");//导航
        require_once template('recommend');
        footer();
    }
}
else {
    show_msg('pass_worng'); 
}
